#include <iostream>
#include <string>
using namespace std;
string s;
int n;
int main()
{
    string t;
    cin >> s >> n;
    t = s + s;
    int len = s.size();
    int z = len;
    n %= len;
    string ans;
    int idx = len - n;
    while (z--) {
        ans += t[idx++];
    }
    cout << ans << endl;
    return 0;
}